package com.lqe.study.Cookie;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Date;

@WebServlet("/CookieDemo02")
public class CookieDemo02 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");

        Cookie[] cookies = req.getCookies();
        Cookie cookie = new Cookie("hello", "刘庆恩");
        Cookie cookie1 = new Cookie("hello1", "刘庆恩1");
        Cookie cookie2 = new Cookie("hello2", "刘庆恩2");
        resp.getWriter().println(cookie.getName()+cookie.getValue());
        resp.addCookie(cookie);
        resp.addCookie(cookie1);
        resp.addCookie(cookie2);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
